#!/bin/bash
echo '###########################################################################'
echo '###########################################################################'
echo '[INFO] begin to evluate recommender algorithms RMS iterately...'
echo '###########################################################################'
echo '###########################################################################'

stepPercent=5
trainingPercentCeiling=95
trainingPercentFloor=70

percent="0.00"
convert2Percentage() {
    temp=$1
    temp=`echo "scale=2;$temp/100"| bc`
    percent=`printf '%f' $temp`
}


for ((p=$trainingPercentFloor; p<=$trainingPercentCeiling; p=p+5))
do
    trainingSetRatio=$p
    evaluatingSetRatio=$((100-p))
    convert2Percentage $trainingSetRatio
    trainingSetRatio=$percent
    convert2Percentage $evaluatingSetRatio
    evaluatingSetRatio=$percent
    echo '------------------------------------------------------------------'
    echo '[info] begin to evaluate with parameters of: '
    echo "[info] trainingSetRatio = $trainingSetRatio" 
    echo "[info] evaluatingSetRatio = $evaluatingSetRatio" 
    echo '------------------------------------------------------------------'
    java -Xmx2048m -Xms1024m -cp mahout/ com.bestv.mahouttest.BestvMahoutRMSEvaluator \
        /cmsdata/cflab \
        movieviewlog_str_int_-timestamp \
        rms_result_movieviewlog_str_int_-timestamp \
        $trainingSetRatio \
        $evaluatingSetRatio \
        true

    java -Xmx2048m -Xms1024m -cp mahout/ com.bestv.mahouttest.BestvMahoutRMSEvaluator \
        /cmsdata/cflab \
        movieviewlog_str_int_sorted_last_-timestamp \
        rms_result_movieviewlog_str_int_sorted_last_-timestamp \
        $trainingSetRatio \
        $evaluatingSetRatio \
        true

    java -Xmx2048m -Xms1024m -cp mahout/ com.bestv.mahouttest.BestvMahoutRMSEvaluator \
        /cmsdata/cflab \
        movieviewlog_str_int_sorted_max_-timestamp \
        rms_result_movieviewlog_str_int_sorted_max_-timestamp \
        $trainingSetRatio \
        $evaluatingSetRatio \
        true

    java -Xmx2048m -Xms1024m -cp mahout/ com.bestv.mahouttest.BestvMahoutRMSEvaluator \
        /cmsdata/cflab \
        movieviewlog_str_int_sorted_sum_-timestamp \
        rms_result_movieviewlog_str_int_sorted_sum_-timestamp \
        $trainingSetRatio \
        $evaluatingSetRatio \
        true
done



